//
//  XMConOpenBoxResultView.m
//  XunMi
//
//  Created by MacBook on 2024/4/30.
//  Copyright © 2024 TieZhu. All rights reserved.
//

#import "XMConOpenBoxResultView.h"
#import "XMGiftModel.h"

@interface XMConOpenBoxResultView ()
@property (weak, nonatomic) IBOutlet UIImageView *imgV;
@property (weak, nonatomic) IBOutlet UILabel *nameLa;
@property (weak, nonatomic) IBOutlet UIButton *openButton;

@end

@implementation XMConOpenBoxResultView

- (void)awakeFromNib {
    [super awakeFromNib];
    NSString *goldStr = kStringFormat(@"消耗%@金币", kGlobalVariables.appConfig.chat.blind_box_golds.stringValue);
    NSString *titleStr = kStringFormat(@"再开一次\n%@", goldStr);
    NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithString:titleStr];
    
    [attStr addAttributes:@{
        NSFontAttributeName: [UIFont fontWithName:@"PingFangSC-Medium" size:18], NSForegroundColorAttributeName: UIColor.whiteColor
    } range:[titleStr rangeOfString:@"再开一次"]];
    
    [attStr addAttributes:@{
        NSFontAttributeName: kUIFont(12), NSForegroundColorAttributeName: kHEX(@"#FFB7B7")
    } range:[titleStr rangeOfString:goldStr]];
    self.openButton.titleLabel.numberOfLines = 0;
    self.openButton.titleLabel.textAlignment = NSTextAlignmentCenter;
    [self.openButton setAttributedTitle:attStr forState:UIControlStateNormal];
}

- (void)setModel:(XMGiftModel *)model {
    _model = model;
    [self.imgV sd_setImageWithURL:kStringToUrl(model.image.file_url) placeholderImage:kDefaultCoverImg];
    self.nameLa.text = kStringFormat(@"%@x1", model.name);
}

- (IBAction)close:(id)sender {
    [GKCover hideCover];
}

- (IBAction)open:(id)sender {
    if (self.openBlock) {
        self.openBlock();
    }
}

@end
